const { numberUtil } = require('../util')
const env = process.env.NODE_ENV
const isDev = env === 'dev'
function Performance () {
  this.startTime = 0
}
Performance.prototype = {
  start () {
    this.startTime = (new Date()).getTime()
  },
  getStartTime () {
    return this.startTime
  },
  getNowTime () {
    return (new Date()).getTime()
  },
  print (text) {
    const now = (new Date()).getTime()
    const times = numberUtil.keepTwoDecimals((now - this.startTime) / 1000)
    if (isDev) {
      console.log(`${text}-耗时：${times}秒`)
    }
    return times
  }
}
module.exports = Performance
